package org.rzp.ideaplug.statistic.setting;

import com.intellij.ui.components.JBCheckBox;
import com.intellij.util.ui.FormBuilder;

import javax.swing.*;

public class StatisticPushSettingComponent {

    private final JPanel settingPanel;

    private final JTextField userField = new JTextField();

    private final JTextField urlField = new JTextField();

    private final JBCheckBox open = new JBCheckBox("加载项目后自动提交");

    private final JBCheckBox close = new JBCheckBox("关闭项目前自动提交");

    public StatisticPushSettingComponent() {
        settingPanel = FormBuilder.createFormBuilder().addLabeledComponent(new JLabel("用户信息 : "), userField, 1)
                .addLabeledComponent(new JLabel("提交地址 : "), urlField, 1)
                .addComponent(open, 1)
                .addComponent(close, 1)
                .addComponentFillVertically(new JPanel(), 0).getPanel();
    }


    public JPanel getSettingPanel() {
        return settingPanel;
    }


    public void settingUser(String user) {
        userField.setText(user);
    }

    public String getUser() {
        return userField.getText();
    }

    public void settingUrl(String url) {
        urlField.setText(url);
    }

    public String getUrl() {
        return urlField.getText();
    }

    public void settingOpen(boolean check) {
        open.setSelected(check);
    }

    public boolean getOpen() {
        return open.isSelected();
    }


    public void settingClose(boolean check) {
        close.setSelected(check);
    }

    public boolean getClose() {
        return close.isSelected();
    }
}
